import Utility.InodeCache
import Utility.Tmp.Dir
import Utility.CopyFile
+import Utility.OpenFd
import qualified Database.Keys.Handle
import qualified Utility.RawFilePath as R
import qualified Utility.FileIO as F
#else
#if MIN_VERSION_unix(2,8,0)
let open = do
- fd <- openFd (fromOsPath f) ReadOnly
- (defaultFileFlags { nofollow = True, cloexec = True })
+ fd <- openFdWithMode (fromOsPath f) ReadOnly Nothing
+ (defaultFileFlags { nofollow = True })
+ (CloseOnExecFlag True)
fdToHandle fd
in bracket open hClose readhandle
#else
subject="""comment 6"""
date="2025-09-04T18:24:33Z"
content="""
-Note that `openFile` is not the only one that would need to be dealt with.
-Also `withFile`, `openBinaryFile`, and `withBinaryFile`.
+`openFile` is not the only one that would need to be dealt with.
+Also `withFile`, `openBinaryFile`, `withBinaryFile`, `appendFile`,
+and `openTempFile`, `readFile, and `writeFile` (including `L.` versions).
-And, since none of those provide a way to set CloseOnExec, they would have
-to be changed to use `openFd` with CloseOnExec, and then mkHandleFromFD.
+Since none of those provide a way to set CloseOnExec, they would have
+to be changed to be implemented using `openFd` with CloseOnExec, and
+then mkHandleFromFD. Or rewritten to use
+<https://hackage.haskell.org/package/file-io-0.1.5/docs/src/System.File.OsPath.Internal.html#openFileWithCloseOnExec>
I have checked and none of those are ever used to create a handle that is
intentionally passed to a child process. The only uses of `handleToFd`
Also there are a few uses of `openFd` that don't set CloseOnExec.
-And possibly also some libraries might open files, I don't know.
+There is also the problem that any haskell library that does anything
+with a file might use any of the above internally without setting
+close-on-exec.
"""]]